import AppConfig from "../config/AppConfig";

/**Laya原生对象池+ */
export default class PoolObj extends Laya.Pool {

    private static objKeys: Laya.StringKey;

    static getItemByClass(sign: string, cls: new () => any) {
        let key = this.getkey(sign);
        return super.getItemByClass(key, cls)
    }

    static recover(sign: string, item: any): void {
        let key = this.getkey(sign);
        super.recover(key, item);
    }

    static getPoolBySign(sign: string): any[] {
        let key = this.getkey(sign);
        return super.getPoolBySign(key);
    }

    static clearBySign(sign: string): void {
        let key = this.getkey(sign);
        super.clearBySign(key);
    }

    private static getkey(sign: string) {
        if (AppConfig.Debug) {
            return sign;
        }

        if (this.objKeys == null) {
            this.objKeys = new Laya.StringKey();
        }

        return this.objKeys.add(sign) + "";
    }
}